﻿; (function (window, undefined, $) {
        var submiting = false;
        $('#frmEdit').validator({
            rules: {

            },
            fields: {
                '#Name': 'required',
                //'#Headportrait': 'required',
                '#Education': 'required',
                '#WorkingYears': 'required',
                '#Graduated': 'required',
                '#Businessbg': 'required',
                '#Pastagencies': 'required'
                //'#Peopleremark': 'required'
            },
            valid: function (form) {
                if (submiting) {
                    return;
                }
                submiting = true;
                FormSubmit(form, function(res) {
                    if (res.status > 0) {

                        alert(res.message);
                        window.location.href = "/Admin/Fund/FundPeopleList";
                    } else if (res.status == -3) {
                        alert(res.message);

                    } else {
                        alert(res.message);
                        window.location.href = "/Admin/Fund/FundPeopleList";

                    }
                    submiting = false;
                });
            }
        });

    util.getnumber = function(id, num) {
        num = num.replace(/[^0-9|\.]/g, ''); //清除字符串中的非数字非.字符
        $('#' + id).val(num);
    };

    $("#btnSave").click(function (e) {
        //var img = document.getElementById("imgShow");
        //$("#imgshow").val(img.src);

        $("#frmEdit").submit();
    });
    $("#btnReturn").click(function (e) {
        window.location.href = "/Admin/Fund/FundPeopleList";
    });

    //init();
    ////初始化  
    //function init() {

    //    //初始化图片上传  
    //    var btnImg = document.getElementById("btnUploadImg");
    //    var img = document.getElementById("imgShow");

    //    var TitlePic = document.getElementById("TitlePic");
    //    var Pictures = document.getElementById("Pictures");
    //    var fileName = document.getElementById("fileName");

    //    g_AjxUploadImg(btnImg, img, TitlePic, Pictures, fileName);
    //}
    //var g_AjxTempDir = "/FileUpload/";

    ////图片上传  
    //function g_AjxUploadImg(btn, img, TitlePic, Pictures, fileName) {
    //    var button = btn, interval;
    //    new AjaxUpload(button, {
    //        action: options.uploadUrl,
    //        data: {},
    //        name: 'myfile',
    //        onSubmit: function (file, ext) {
    //            if (!(ext && /^(jpg|JPG|png|PNG|gif|GIF)$/.test(ext))) {
    //                alert("您上传的图片格式不对，请重新选择！");
    //                return false;
    //            }
    //        },
    //        onComplete: function (file, response) {
    //            flagValue = response;
    //            if (flagValue == "-1") {
    //                alert("您上传的图片格式不对，请重新选择！");
    //            }
    //            else if (flagValue == "-2") {
    //                alert("您上传的图片大于200K，请重新选择！");
    //            }
    //            else if (flagValue == "-3") {
    //                alert("图片上传失败！");
    //            }
    //            else {
    //                var strs = new Array();
    //                strs = response.split("/");

    //                var Pictures2 = "";
    //                var fileName2 = "";
    //                for (var i = 0; i < strs.length; i++) {
    //                    if (i == 0) {
    //                        TitlePic.value = strs[i];
    //                    } else if (i == 1) {
    //                        Pictures.value = strs[i];
    //                        Pictures2 = strs[i];

    //                    } else if (i == 2) {
    //                        fileName2 = strs[i];
    //                    }
    //                }
    //                alert("PATH:" + g_AjxTempDir + fileName2 + "/" + Pictures2);
    //                img.src = g_AjxTempDir + fileName2 + "/" + Pictures2;
    //                $("#Headportrait").val(img.src);
    //                fileName.value = g_AjxTempDir + fileName2 + "/" + Pictures2;
    //            }
    //        }
    //    });
    //}

})(window, undefined, jQuery);